package com.ruoyi.web.controller.bus;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bus.domain.WitComment;
import com.ruoyi.bus.service.IWitCommentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 点评Controller
 * 
 * @author caiyanshan
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/bus/comment")
public class WitCommentController extends BaseController
{
    @Autowired
    private IWitCommentService witCommentService;

    /**
     * 查询点评列表
     */
    @PreAuthorize("@ss.hasPermi('bus:comment:list')")
    @GetMapping("/list")
    public TableDataInfo list(WitComment witComment)
    {
        startPage();
        List<WitComment> list = witCommentService.selectWitCommentList(witComment);
        return getDataTable(list);
    }

    /**
     * 导出点评列表
     */
    @PreAuthorize("@ss.hasPermi('bus:comment:export')")
    @Log(title = "点评", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WitComment witComment)
    {
        List<WitComment> list = witCommentService.selectWitCommentList(witComment);
        ExcelUtil<WitComment> util = new ExcelUtil<WitComment>(WitComment.class);
        return util.exportExcel(list, "comment");
    }

    /**
     * 获取点评详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:comment:query')")
    @GetMapping(value = "/{commentId}")
    public AjaxResult getInfo(@PathVariable("commentId") Long commentId)
    {
        return AjaxResult.success(witCommentService.selectWitCommentById(commentId));
    }

    /**
     * 新增点评
     */
    @PreAuthorize("@ss.hasPermi('bus:comment:add')")
    @Log(title = "点评", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WitComment witComment)
    {
        return toAjax(witCommentService.insertWitComment(witComment));
    }

    /**
     * 修改点评
     */
    @PreAuthorize("@ss.hasPermi('bus:comment:edit')")
    @Log(title = "点评", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WitComment witComment)
    {
        return toAjax(witCommentService.updateWitComment(witComment));
    }

    /**
     * 删除点评
     */
    @PreAuthorize("@ss.hasPermi('bus:comment:remove')")
    @Log(title = "点评", businessType = BusinessType.DELETE)
	@DeleteMapping("/{commentIds}")
    public AjaxResult remove(@PathVariable Long[] commentIds)
    {
        return toAjax(witCommentService.deleteWitCommentByIds(commentIds));
    }
}
